from fastapi import FastAPI
from app.api.v1.router import router as api_v1_router
from app.core.settings import settings
from app.db.session import create_all_tables

app = FastAPI(title="FastAPI with MySQL")

# 启动时创建数据库表（需提前在 MySQL 中创建 DB_NAME 对应的数据库）
# @app.on_event("startup")
# def on_startup():
#     create_all_tables()

# prefix=settings.API_V1_STR
app.include_router(api_v1_router, prefix=settings.API_V1_STR)

@app.get("/")
def read_root():
    return {"message": "FastAPI with MySQL is running!"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)